﻿Imports System.IO
Imports FastReport
Imports FastReport.Utils
Public Class frmReportCurrentInv
    Dim _mysql As New ClsSQLhelper
    Dim Strsql As String

    Private Sub frmReportCurrentInv_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
        Try
            Dim Rpt_Form As String
            Strsql = "Select items.*,typeitem.Type_Name,department_name,section_name,categories.cate_name from items "
            Strsql = Strsql & " left join typeitem on items.Item_Type = typeitem.Type_ID "
            Strsql = Strsql & " left join department on items.Department = department.department_ID "
            Strsql = Strsql & " left join sections on typeitem.section = sections.section_ID "
            Strsql = Strsql & " left join categories on sections.Cate_ID = categories.Cate_ID "
            Strsql = Strsql & " where discharge <> 'Y'"
            Dim DS_Whas As New DataSet
            DS_Whas = _mysql.GetMYSQLDataset(Strsql, "items")



            Dim ReportPage As New FastReport.ReportPage
            With ReportPage
                '  .CreateUniqueName()
                .Name = "Page1"
                Report1.Pages.Add(ReportPage)
                ReportPage.ReportTitle = New FastReport.ReportTitleBand
                ReportPage.ReportTitle.CreateUniqueName()
                ReportPage.ReportTitle.Height = 1 * Units.Centimeters

                ReportPage.PageHeader = New FastReport.PageHeaderBand
                ReportPage.PageHeader.CreateUniqueName()
                ReportPage.PageHeader.Height = 0.75 * Units.Centimeters

                Dim Band As New FastReport.DataBand
                ReportPage.Bands.Add(Band)
                Band.CreateUniqueName()
                Band.Height = 2 * Units.Centimeters

                ReportPage.PageFooter = New FastReport.PageFooterBand
                ReportPage.PageFooter.CreateUniqueName()
                ReportPage.PageFooter.Height = 0.5 * Units.Centimeters

                Report1.Save(My.Settings.ReportPath & "currentinv.frx")
                Rpt_Form = "currentinv.frx"

            End With

            Report1.Load(My.Settings.ReportPath & Rpt_Form)
            Report1.AutoFillDataSet = True
            Report1.RegisterData(DS_Whas)
            Report1.GetDataSource("items").Enabled = True
            Report1.Refresh()
            Report1.Design()
        Catch ex As Exception
            MsgBox(ex.Message)
        End Try

    End Sub
End Class